/*
 * @Description: 
 * @Version: 1.0
 * @Autor: lairensi
 * @Date: 2021-08-31 11:42:46
 * @LastEditors: lairensi
 * @LastEditTime: 2021-08-31 12:41:29
 */

import 'package:flutter/material.dart';

class UserInfoProvider extends ChangeNotifier {
  // 用户信息
  String cloudUser = "";
  String companiesInfo = "";
  String password = "";
  String salt = "";
  String roleIds = "";
  List permissionsAdmin = [
    // 'value'
  ];
  String pid = "";
  String username = "";
  String fullName = "";
  String mobile = "";
  String identityType = "";
  bool state = true;
  String openId = "";
  String companyId = "";
  String companyCode = "";
  int stationId = 0;
  String companyName = "";
  bool controllable = true;
  String allowAppCtl = "";
  List companies = [
    // {
    //       permName: 生产管理,
    //       permCode: scgl,
    //       permission: scgl,
    //       permType: public,
    //       permStyle: menu,
    //       display: false,
    //       permUrl: 生产管理,
    //       appCode: null,
    //       mdisplay: null,
    //       murl: null,
    //       micon: null,
    //       mdesc: null
    //     }
  ];
  String loginType = "";

  // 全量更新用户,一般在登录后执行一次
  changeUserName(userinfo) {
    // 用户信息
    print('用户信息=======');
    print(userinfo);

    cloudUser = userinfo['username'];
    companiesInfo = userinfo['companiesInfo'];
    password = userinfo['password'];
    salt = userinfo['salt'];
    roleIds = userinfo['roleIds'];
    permissionsAdmin = userinfo['permissionsAdmin'] != null
        ? userinfo['permissionsAdmin']
        : [];
    pid = userinfo['pid'];
    username = userinfo['username'];
    fullName = userinfo['fullName'];
    mobile = userinfo['mobile'];
    identityType = userinfo['identityType'];
    state = userinfo['state'];
    openId = userinfo['openId'];
    companyId = userinfo['companyId'];
    companyCode = userinfo['username'];
    stationId = userinfo['stationId'];
    companyName = userinfo['companyName'];
    controllable = userinfo['controllable'];
    allowAppCtl = userinfo['allowAppCtl'];
    companies = userinfo['companies'] != null ? userinfo['companies'] : [];
    loginType = userinfo['loginType'];

    notifyListeners();
  }
}
